import type { App } from 'vue'

import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { ElLoading, ElMessage, ElMessageBox, ElNotification } from 'element-plus/es'

const plugins = [ElMessage, ElNotification, ElMessageBox, ElLoading]

export async function setupElementPlus(app: App<Element>) {
    // 服务型组件需要单独注册
    plugins.forEach((plugin) => {
        app.use(plugin)
    })

    // 注册图标组件
    for (const [key, component] of Object.entries(ElementPlusIconsVue))
        app.component(key, component)
}
